﻿// Learn more about F# at http://fsharp.net
#if INTERACTIVE
#r @"C:\Documents and Settings\alexey-suvorov\My Documents\Visual Studio 2010\Projects\Vipiska\Vipiska\HtmlAgilityPack.dll"
#endif
namespace SimpleSolutions.Vipiska

open HtmlAgilityPack
open System
open System.IO

module Program =
    type PayObject =
            Currency : string
            Description : string
            Sum : Double

    type Category =
            Name : string

    type CategorisedPay =
            Cat : Category
            Pay : PayObject

    [<EntryPoint>]
    let Main args =
        let doc = new HtmlAgilityPack.HtmlDocument()
        doc.Load (@"C:\Documents and Settings\alexey-suvorov\Desktop\Vipiska\9113_Aug11.html",true)
        let rows = doc.DocumentNode.SelectNodes("//tr[@class='rowTrnData']")
        let construct (x:HtmlNode) =
            let cls = x.SelectNodes("td")
            let gt (n:int) = cls.[n].InnerText  
            let curr = gt 5
            let sum = gt 6 |> Double.Parse
            let dsc = gt 4
            { Currency = curr; Description = dsc; Sum = sum }
        let pays = Seq.map construct rows
        
        0


(*
<tr class="rowTrnData">
<td class="trnTD1"><BR></td>
<td class="trnTD1c">30ÈÞË</td>
<td class="trnTD1c">02ÀÂÃ</td>
<td class="trnTD1c">921826</td>
<td class="trnTD1">R1082003, PULKOVSKY ST.PETERSBURG RUS</td>
<td class="trnTD1c">RUR</td>
<td class="trnTD1r">154.30</td>
<td class="trnTD2">154.30</td>
</tr>
*)